﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Platformer
{
    public class AudioManager
    {
        public bool IsPlayingMusic
        {
            get { return isPlayingMusic; }
        }
        bool isPlayingMusic = false;

        public bool IsPlayingSound
        {
            get { return isPlayingSound; }
        }
        bool isPlayingSound = false;

        public float Volume
        {
            set 
            {
                if (value < 0f)
                    MediaPlayer.Volume = 0f;
                else if (value > 1f)
                    MediaPlayer.Volume = 1f;
                else
                    MediaPlayer.Volume = value; 
            }
            get { return MediaPlayer.Volume; }
        }

        /// <summary>
        /// Handles all the audio stuff of the game.
        /// </summary>
        public AudioManager()
        {

        }

        public void PlayMusic()
        {
            
        }

        /// <summary>
        /// Plays a sound effect. If one is already playing, it will stop it, then play the requested sund.
        /// </summary>
        public void PlaySound()
        {
            if (isPlayingSound)
            {
                MediaPlayer.Stop();
            }
        }

        public void Stop()
        {
            MediaPlayer.Stop();
        }

        public void Pause()
        {
            MediaPlayer.Pause();
        }

        public void Resume()
        {
            MediaPlayer.Resume();
        }
    }
}
